using System;
using System.Threading.Tasks;
using Codeflows.Results;
using Codeflows.Tracking;

namespace Codeflows.Dispatch.ResultHandlers
{
    class PendingHandler : ResultHandler<PendingResult>
    {
        readonly Func<Task<Result>, Result> _continuation;
        public PendingHandler(Func<Task<Result>, Result> continuation)            
        {
            _continuation = continuation;
        }

        protected override void Handle(CodeflowInstance instance, PendingResult result)
        {
            result.ContinueWith(_continuation);
        }
    }
}